package com.roocon.design_pattern.chapter08_active_object;

public class MakerClientThread extends Thread {

  private final ActiveTask activeTask;
  private final char fillChar;

  public MakerClientThread(ActiveTask activeTask,String name) {
    this.activeTask = activeTask;
    this.fillChar = name.charAt(0);
  }

  @Override public void run() {
    for (int i = 0; true; i++) {
      Result result = activeTask.doWorkForResult(i + 1, fillChar);
      try {
        Thread.sleep(20);
        String value = (String) result.getResultValue();
        System.out.println(Thread.currentThread().getName() + ": value = " + value);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
